#include <mpi.h> // OpenMPI header file
#include <omp.h> // OpenMP header file
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <tr1/unordered_map>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;
using namespace tr1;

typedef unordered_map<unsigned int, unsigned int> INT_INT_MAP;
typedef vector<float> FLOAT_VEC;
typedef vector<unsigned int> INT_VEC;

struct Entry {
	int hash, idx;
	float val;

	Entry(int _hash, int _idx, float _val) {
		hash = _hash;
		idx = _idx;
		val = _val;
	}
};

bool compare(const Entry& x, const Entry& y) {
	return x.hash < y.hash;

}

typedef vector<Entry> ENTRY_VEC;


class CRoP_AMM {
public :
	CRoP_AMM(int argc, char **argv);

private :
	INT_INT_MAP h1, h2;
	int p, rank;
	void parse_file(const char * filename);
	int val(int x, INT_INT_MAP &h);
	void do_product(ENTRY_VEC col, ENTRY_VEC row, int count[]);
	void crop(FLOAT_VEC col, FLOAT_VEC row);
};
